#include "protocol_center.h"

#include <map>

std::map<std::string, ProtocolCenter::Protocol> ProtocolCenter::m_protocol_map = {

    {"http",
     Protocol{.m_protocol_name = "http", .m_protocol_port = 80, .m_use_tls_or_dtls = 0, .m_protocol_type = PROTOCOL_TCP}  },
    {"rtmp",
     Protocol{.m_protocol_name = "rtmp", .m_protocol_port = 1935, .m_use_tls_or_dtls = 0, .m_protocol_type = PROTOCOL_TCP}},
    {"https",
     Protocol{.m_protocol_name = "https", .m_protocol_port = 443, .m_use_tls_or_dtls = 1, .m_protocol_type = PROTOCOL_TCP}},
    {"tcp",
     Protocol{.m_protocol_name = "tcp", .m_protocol_port = 0, .m_use_tls_or_dtls = 0, .m_protocol_type = PROTOCOL_TCP}    },
    {"udp",
     Protocol{.m_protocol_name = "udp", .m_protocol_port = 0, .m_use_tls_or_dtls = 0, .m_protocol_type = PROTOCOL_UDP}    },
    {"stun",
     Protocol{.m_protocol_name = "udp", .m_protocol_port = 19302, .m_use_tls_or_dtls = 1, .m_protocol_type = PROTOCOL_UDP}}
};

ProtocolCenter::Protocol ProtocolCenter::FindProtocol(const std::string & name)
{
    auto iter = m_protocol_map.find(name);
    if (iter != m_protocol_map.end())
    {
        return iter->second;
    }
    return Protocol{};
}
